package com.web.surf.sample.eshop.faces.managed.beans;

import com.web.surf.sample.eshop.dto.interfaces.IProperty;
import com.web.surf.sample.eshop.faces.core.AbstractBean;

/**
 * Address substance
 * @author SavenkoNV
 */
public class AddressBean extends AbstractBean {

	/**
	 * Address properties
	 * @author SavenkoNV
	 */
	public enum AddressProperties implements IProperty {

		ADDRESS_ID("address_id"),
		CUSTOMER_NAME("cust_name"), 
		COUNTRY("country"),
		CITY("city"),
		STREET_NAME("street"),
		STREET_KIND("street_type"),
		HOUSE("house"),
		BUILDING("building"),
		FLAT("flat"),
		CONTACT_PHONE("phone"),
		ZIP_CODE("zip");

		private String databaseName;

		AddressProperties(String databaseName) {
			this.setDatabaseName(databaseName);
		}

		public void setDatabaseName(String databaseName) {
			this.databaseName = databaseName;
		}

		public String getDatabaseName() {
			return databaseName;
		}
	}
	
	
	public AddressBean() {
		setAddressID(generateID());
	}	
	
	public void clear() {
		setAddressID(generateID());
		setCustomerName(null);
		setCountry(null);
		setCity(null);
		setStreetName(null);
		setStreetKind(null);
		setHouse(null);
		setBuilding(null);
		setFlat(null);
		setContactPhone(null);
		setZipCode(null);		
	}
	
	public boolean equals(Object o) {
		if ((o instanceof AddressBean)&&(((AddressBean)o).getAddressID()
				==this.getAddressID())) {
			return true;
		}
		else {
			return false;		
		}
	}
	
	public int hashCode() {
		return this.getAddressID().hashCode();
	}	
	
	//Getters
	public String getAddressID() {
		return getProperty(AddressProperties.ADDRESS_ID, String.class);
	}
	
	public String getCustomerName() {
		return getProperty(AddressProperties.CUSTOMER_NAME, String.class);
	}
	
	public String getCountry() {
		return getProperty(AddressProperties.COUNTRY, String.class);
	}
	
	public String getCity() {
		return getProperty(AddressProperties.CITY, String.class);
	}
	
	public String getStreetName() {
		return getProperty(AddressProperties.STREET_NAME, String.class);
	}
	
	public String getStreetKind() {
		return getProperty(AddressProperties.STREET_KIND, String.class);
	}
	
	public String getHouse() {
		return getProperty(AddressProperties.HOUSE, String.class);
	}
	
	public String getBuilding() {
		return getProperty(AddressProperties.BUILDING, String.class);
	}
	
	public String getFlat() {
		return getProperty(AddressProperties.FLAT, String.class);
	}
	
	public String getContactPhone() {
		return getProperty(AddressProperties.CONTACT_PHONE, String.class);
	}
	
	public String getZipCode() {
		return getProperty(AddressProperties.ZIP_CODE, String.class);
	}
	
	//Setters
	public void setAddressID(String addressID) {
		addProperty(AddressProperties.ADDRESS_ID, addressID);
	}	

	public void setCustomerName(String customerName) {
		addProperty(AddressProperties.CUSTOMER_NAME, customerName);
	}

	public void setCountry(String country) {
		addProperty(AddressProperties.COUNTRY, country);
	}

	public void setCity(String city) {
		addProperty(AddressProperties.CITY, city);
	}

	public void setStreetName(String streetName) {
		addProperty(AddressProperties.STREET_NAME, streetName);
	}	

	public void setStreetKind(String streetKind) {
		addProperty(AddressProperties.STREET_KIND, streetKind);
	}	

	public void setHouse(String house) {
		addProperty(AddressProperties.HOUSE, house);
	}	

	public void setBuilding(String building) {
		addProperty(AddressProperties.BUILDING, building);
	}	

	public void setFlat(String flat) {
		addProperty(AddressProperties.FLAT, flat);
	}

	public void setContactPhone(String contactPhone) {
		addProperty(AddressProperties.CONTACT_PHONE, contactPhone);
	}

	public void setZipCode(String zipCode) {
		addProperty(AddressProperties.ZIP_CODE, zipCode);
	}
	
}
